package net.tribal.comic.entities

import java.util.Date;

class Comment {

	//	Persistence Attributes
	String 	text
	
	boolean moderationRequest 	= false
	boolean disabled 			= false
	
	Integer up = 0
	Integer down = 0
	
	Date 	dateCreated
	Date 	lastUpdated
	
	User createdBy
	//	DB Relations & Constraits
	static 	belongsTo = User
	
	static hasMany =	[userComments : User]
	
	static mapping = {
		userComments joinTable: "user_comments"
		sort dateCreated:"desc"
		
    }
	
	//	DB Constraits
	static constraints = {
		text(blank:true, maxSize:1000)
	}
	
	boolean equals(obj){
        boolean result
        if(obj == null)
                result = false
        else if(!(obj instanceof Comment))
                result = false
        else
                result = id.equals(obj.id)
        
        return result
	}
	
	int hashCode(){
		def hash = 1;
	    hash = hash * 31 + (id == null ? 0 : id.hashCode());
	    return hash;
	}
}